#
# Redis Dockerfile
#
# https://gitee.com/wzun/redis.git
#

# Pull base image.
#FROM dockerfile/ubuntu
FROM debian:latest

#http://download.redis.io/releases/redis-4.0.10.tar.gz

ENV REDIS_NAME=redis-4.0.10


RUN \
	cp -a /etc/apt/sources.list /etc/apt/sources.list.bak && \
	sed -i "s@http://ftp.debian.org@https://mirrors.huaweicloud.com@g" /etc/apt/sources.list && \
#	apt-get install apt-transport-https ca-certificates && \
	apt-get update && \
	apt-get -y install gcc automake autoconf libtool make wget 
	
# Install Redis.
RUN \
  cd /tmp && \
  wget http://download.redis.io/releases/$REDIS_NAME.tar.gz && \
  tar xzf $REDIS_NAME.tar.gz && \
  cd $REDIS_NAME && \
  make && \
  make install && \
  cp -f src/redis-sentinel /usr/local/bin && \
  mkdir -p /etc/redis && \
  cp -f *.conf /etc/redis && \
  rm -rf /tmp/$REDIS_NAME && \
  sed -i 's/^\(bind .*\)$/# \1/' /etc/redis/redis.conf && \
  sed -i 's/^\(daemonize .*\)$/# \1/' /etc/redis/redis.conf && \
  sed -i 's/^\(dir .*\)$/# \1\ndir \/data/' /etc/redis/redis.conf && \
  sed -i 's/^\(logfile .*\)$/# \1/' /etc/redis/redis.conf && \
  sed -i 's/^\(protected-mode .*\)$/# \1\nprotected-mode no/' /etc/redis/redis.conf
  
RUN \
  apt-get clean && \
  apt-get autoclean
 
# Define mountable directories.
VOLUME ["/data"]

# Define working directory.
WORKDIR /data

# Define default command.
CMD ["redis-server", "/etc/redis/redis.conf"]

# Expose ports.
EXPOSE 6379
